<?php
include "../../fun.php";
$db=conndb();
isLogin();
$sortname=isset($_GET["sortname"])?$_GET["sortname"]:'';
$sortid=isset($_GET["sortid"])?$_GET["sortid"]:'';
$page=isset($_GET["page"])?$_GET["page"]:'1';
$limit=isset($_GET["limit"])?$_GET["limit"]:'5';
$where='';
$sql_count='';
if ($sortid) {
    $where.="and b.id='{$sortid}'";
}
if ($where) {
    $where=" where".substr($where, 3);
}
$sql_count="select count(*) as total from sortclass";
$res_count=query1($db, $sql_count, false);
$count=$res_count["total"];
$start=($page-1)*$limit;
// a表获取所有信息  b获取类别名称
$sql="select a.*,b.sortname as parentname from sortclass as a LEFT JOIN sortclass as b on a.parentid=b.id {$where} order by a.id limit {$start},{$limit}";
$res=query1($db, $sql);
$data=["code"=>0,"msg"=>"操作成功","data"=>$res,"count"=>$count,"limit"=>$limit];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
